class Solution:

    def lengthOfLongestSubstring(self, s: str) -> int:
        st = set()
        ans = l = 0
        for i, v in enumerate(s):
            while v in st:
                st.remove(s[l])
                l += 1
            st.add(v)
            ans = max(ans, len(st))
        return ans